const Mock =require('mockjs');
const getComponentList = require('./getComponentList');
const Random = Mock.Random;

function getStatList(opt = {} ) {
    const {len = 10} = opt;
    const list = [];
    console.log('getStatList', len);
    const componentList = getComponentList()
    for(let i=0; i<len; i++){
        const stat = {
            _id: Random.id(),
        }
        componentList.forEach(c => {
            const {fe_id, type, props} = c;
            switch(type){
                case "questionTitle":
                    break;
                case "questionInput":
                    stat[fe_id] = Random.ctitle();
                    break;
                case "questionParagraph":
                    break;
                case "questionRadio":
                    stat[fe_id] = Random.ctitle();
                    break;
                case "questionRadio":
                    stat[fe_id] = props.options[0].text;
                    break;
                case "questionCheckbox":
                    stat[fe_id] = `${props.list[0].text},${props.list[1].text}`;
                    break;
            }
        });
        list.push(stat);
    }
    return list;
}


module.exports = getStatList;